package com.service.collect.impl;

import java.util.List;

import com.dao.CollectDao;
import com.entity.Collect;
import com.service.collect.CollectService;
import com.utils.MybatisUtil;

public class CollectServiceImpl implements CollectService{

	/**
	 * 新增收藏夹信息
	 */
	@Override
	public int finAddCollect( int userid,int id ,int type) {
		CollectDao coll = MybatisUtil.getMapper(CollectDao.class);
		int row = coll.addCollect(userid,id , type);
		MybatisUtil.closeCommit();
		return row;
	}

	/**
	 * 删除指定用户的收藏信息
	 */
	@Override
	public int finRemoveCollect(int userid, int id) {
		CollectDao coll = MybatisUtil.getMapper(CollectDao.class);
		int row = coll.removeCollect(userid, id);
		MybatisUtil.closeCommit();
		return row;
	}

	/**
	 * 根据ID查询收藏信息
	 */
	@Override
	public Collect finCollectUserCount(int id) {
		CollectDao coll = MybatisUtil.getMapper(CollectDao.class);
		Collect coll2 = coll.CollectUserCount( id);
		MybatisUtil.closeCommit();
		return coll2;
	}

	@Override
	/**
	 * 根据用户id查询收藏信息
	 */
	public List<Collect> finselectByUserId(int userId) {
		CollectDao coll = MybatisUtil.getMapper(CollectDao.class);
		List<Collect> list = coll.selectByUserId(userId);
		MybatisUtil.closeCommit();
		return list;
	}

	@Override
	public int finUserProCount(int userid) {
		CollectDao coll = MybatisUtil.getMapper(CollectDao.class);
		int userProCount = coll.userProCount(userid);
		MybatisUtil.closeCommit();
		return userProCount;
	}

}
